<?php
/**
 * Created by PhpStorm.
 * User: zq
 * Date: 2017/2/20
 * Time: 14:20
 */

namespace Admin\Controller;


use Common\Model\UserModel;
use Think\Controller;


class LoginController extends Controller
{
    protected $db;
    public function __construct()
    {
        parent::__construct();
        $this->db =new UserModel();
    }

    public function index(){
        if(IS_POST){
            if($this->db->login()){
                $this->success('登录成功',U('Index/index'),'success');die;
            }else{
                $this->error($this->db->getError());
            }
        }
        $this->display();
    }
    public function code(){
        $Verify =new \Think\Verify();
        $Verify->fontSize = 30;
        $Verify->length   = 2;
        $Verify->useNoise = false;
        $Verify->entry();
    }
    public function out(){
        session(null);
        $this->success('退出成功',u('admin/login/index'),'success');die;
    }


}